using System.Collections.Generic;
using aprogblog.App.MetaWeblog;
using aprogblog.App.Models;
using aprogblog.Domain;

namespace aprogblog.Specs.Fixtures {

    public class WeblogServiceFixture {
        
        WeblogService WeblogService { get { return new WeblogService(); }}
        
        public string FeedPath { set { Settings.FeedPath = value; }}
        
        public List<Entry> ReadEntry(string Id) { 
            try { return new List<Entry> {
                WeblogService.GetPost(Id, null, null).ToEntry()
            };} catch { return new List<Entry>();}
        } 

        public List<Entry> ReadRecentEntries(int NumberOfEntries) { return 
            WeblogService.GetRecentPosts(null, null, null, NumberOfEntries).ToEntries()
        ;}

        public string AddEntry(string Title, string Description) { return
            WeblogService.AddPost(null, null, null, new Post {
                title = Title, 
                description = Description,
            }, false)
        ;}
        
        public void DeleteEntry(string Id) {
            WeblogService.DeletePost(null, Id, null, null, false);
        }
    }
}